//
//  AppMacro.h
//  iOSCodeProject
//
//  Created by Fox on 14-7-17.
//  Copyright (c) 2014年 翔傲信息科技（上海）有限公司. All rights reserved.
//


#import "AppDelegate.h"

#define Jpush_AppKey @"55cf4548267e81d8fd09c6e6"
#define Jpush_isProduction  0



// NSUserDefaults Key
#define  UserDefaultKey_SynchronousDays  @"SynchronousDays"
#define  UserDefaultKey_AppFirstStartOfVersionKey  @"AppFirstStartOfVersionKey"

//拼图tag
#define kPuzzleTag 1003
//相册制作tag
#define kAlbumMadeTag 1004
//相框制作的tag
#define kMadeObjectTag 1005

//程序总委托
#define  appDelegate   ((AppDelegate *)[[UIApplication sharedApplication] delegate])

/**
 *  项目内公共常用宏定义
 */

#ifndef iOSCodeProject_AppMacro_h
#define iOSCodeProject_AppMacro_h

#pragma mark - Format
/**
 *  生成字符串
 *
 *  @param ... 格式化参数
 *
 *  @return 得到的字符串
 */
#define str(...) [NSString stringWithFormat:__VA_ARGS__]

/**
 *  根据名字返回对应的图片
 */
#define img(name) [UIImage imageNamed:name]


#pragma mark - Block

/**
 *  弱引用对象
 *
 *  @param self 当前对象
 *
 *  @return 弱应用对象
 */
#define WEAKSELF typeof(self) __weak weakSelf = self;

/**
 *  强引用对象
 *
 *  @param self 当前对象
 *
 *  @return 强引用对象
 */
#define STRONGSELF typeof(self) __strong strongSelf = self;

#pragma mark - Debug

#ifdef DEBUG

/**
 *  在Debug模式下，输出内容
 */
#define DLOG(fmt, ...)  NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)

/**
 *  在Debug模式下，输出Point信息
 *
 *  @param p 点
 *
 *  @return 点的x和y
 */
#define DLOGPOINT(p)	NSLog(@"%f,%f", p.x, p.y);

/**
 *  在Debug模式下，输出Size信息
 *
 *  @param size 大小
 *
 *  @return 大小的width和height
 */
#define DLOGSIZE(size)	NSLog(@"%f,%f", size.width, size.height);

/**
 *  在Debug模式下，输出Fame信息
 *
 *  @param  p  位置信息
 *
 *  @return 位置的x、y、width和height
 */
#define DLOGRECT(p)	NSLog(@"%f,%f %f,%f", p.origin.x, p.origin.y, p.size.width, p.size.height);

#else

#define DLOG(...)
#define DLOGPOINT(p)
#define DLOGSIZE(p)
#define DLOGRECT(p)

#endif

#pragma mark - Tools methods
/**
 *  判断一个对象是否为空
 *
 *  @param thing 对象
 *
 *  @return 返回结果
 */
static inline BOOL ICIsObjectEmpty(id thing){
    return thing == nil ||
    ([thing isEqual:[NSNull null]]) ||
    ([thing respondsToSelector:@selector(length)] && [(NSData *)thing length] == 0) ||
    ([thing respondsToSelector:@selector(count)]  && [(NSArray *)thing count] == 0);
}

/**
 *  判断一个字符串是否为空
 *
 *  @param string 字符串
 *
 *  @return 返回结果
 */
static inline BOOL ICIsStringEmpty(NSString *string){
    
    if (string == nil || string == NULL) {
        return YES;
    }
    
    if ([string isKindOfClass:[NSNull class]]) {
        return YES;
    }
    
    if ([string isEqualToString:@"<null>"]) {
        return YES;
    }
    
    if ([string isEqualToString:@"(null)"]) {
        return YES;
    }
    
    if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
        return YES;
    }
    
    return NO;
}

//程序全局委托
#ifndef APPLICATIONDELEGATE
#define APPLICATIONDELEGATE   ((AppDelegate*)[[UIApplication sharedApplication] delegate])
#endif

//安全释放
#ifndef RELEASE
#define RELEASE(x)         if(nil != (x)){ [(x) release]; (x) = nil;}
#endif

#pragma mark - iPhone5 adaptation

//是否为iPhone6
#ifndef iPhone6
#define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ?  \
CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#endif

//是否为iPhone6P
#ifndef iPhone6P
#define iPhone6P ([UIScreen instancesRespondToSelector:@selector(currentMode)] ?  \
CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#endif

//是否为iPhone5
#ifndef iPhone5
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ?  \
CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#endif

//是否为iPhone4
#ifndef iPhone4
#define iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ?  \
CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#endif

//设备屏幕高度
#ifndef UIScreenHeight
#define UIScreenHeight   [UIScreen mainScreen].bounds.size.height
#endif

//设备屏幕宽度
#ifndef UIScreenWidth
#define UIScreenWidth    [UIScreen mainScreen].bounds.size.width
#endif

//是否为ios7
#ifndef IOS7
#define IOS7            ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0?YES:NO)
#endif

//是否为ios6
#ifndef IOS6
#define IOS6            ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0?YES:NO)
#endif

//如果为ios7，则返回20的冗余
#ifndef IOS7_PADDING
#define IOS7_PADDING    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0?20:0)
#endif

//区分真机和模拟器
//TARGET_OS_IPHONE  是否为真机
//TARGET_IPHONE_SIMULATOR  是否为模拟器
/*
if (TARGET_OS_IPHONE) {
    //真机
}else{
    //非真机
}
 */


#define DEFAULT_SIGN   @"f0ae367316904c1ab0c81509cb598ade"  //签名字符串
#define NOMORE_DATA    @"暂无数据"      //数据提示
#define EACHPAGE_SIZE  @"10"            //每页加载数据数
#define USER_CURRENT_LOCATION @"userCurrentLocation"

#define ORANGE_COCOR  @"feba5b"  //通用橘色
#define YELLOW_COCOR  @"eaa725"  //通用橘色
#define YELLOW_COCOR_PRESS  @"be8413"  //通用橘色

#define BLUE_COCOR    @"104da8"  //通用蓝色
#define Red_COCOR     @"D43C33"   //红色
#define Nav_COLOR     ColorWithRGB(102, 102, 102) //导航栏背景色
#define TABBAR_TXT_COLOR     ColorWithRGB(166, 165, 166) //Tabbar 点击后按钮效果颜色

#define TAB_BAR_COLOR [UIColor colorForHex:@"1A1D20"] //tabBar背景色
#define VIEWBG_COCOR  [UIColor colorWithRed:219/255.0 green:219/255.0 blue:219/255.0 alpha:1.0]
#define ColorWithRGB(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0]


///////////////////////////////////////////////////////////////////////////////////////
// Senela Add:2016-09-23; 添加全局宏定义－－颜色设置
#define ViewBackgroundColor [UIColor whiteColor]
#define NavTitle_TextColor  [UIColor whiteColor]
 

#define FontSize_12  [UIFont systemFontOfSize:12]
#define FontSize_17  [UIFont systemFontOfSize:17]
#define FontSize_Button    [UIFont systemFontOfSize:16.0f]
#define FontSize_NavTitle  [UIFont systemFontOfSize:19.0f]
///////////////////////////////////////////////////////////////////////////////////////


#define FLY_LINK_01  1
#define FLY_LINK_02  2
#define FLY_LINK_03  3
#define FLY_LINK_04  4
#define FLY_LINK_05  5
#define FLY_LINK_06  6
#define FLY_LINK_07  7
#define FLY_LINK_08  8
#define FLY_LINK_09  9
#define FLY_LINK_10  10


#define NOTLOGIN_ALERT    [UIAlertView alertViewWithTitle:@"" message:@"您还未登录，请先登录" cancelButtonTitle:@"确定" otherButtonTitles:@[@"取消"] onDismiss:^(NSInteger buttonIndex) {} onCancel:^{TTINavigationController *loginNav = [[TTINavigationController alloc] initWithRootViewController:[[UIStoryboard storyboardWithName:@"Login" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginVC"]];[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:loginNav animated:YES completion:^{[[NSUserDefaults standardUserDefaults] setObject:@"special" forKey:@"SPECIALLOGIN"];}];}];


//区分是否为ARC
#if __has_feature(objc_arc)
//compiling with ARC
#else
// compiling without ARC
#endif

#endif
